package com.scrcu.cloud.wechat.home.endpoint.auth.controller;

import com.scrcu.cloud.wechat.home.endpoint.auth.service.WxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "微信相关接口")
@RequestMapping("/wx")
@RestController
@Validated
public class WxController {

    @Autowired
    private WxService wxService;


    @ApiOperation("微信消息配置验证")
    @GetMapping("/mesRecive")
    public String mesRecive(String signature, String timestamp, String nonce, String echostr) {
        //消息合法
        if (wxService.checkSignature(signature, timestamp, nonce)) {
            return echostr;
        }
        return null;
    }
}
